package com.dream.banana.redis.pack.jedis.ihanderitem;

import com.dream.banana.redis.pack.ipackitem.IRedisHashPack;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCommands;
import redis.clients.util.Pool;

/**
 * 躲了一辈子雨，雨会不会很难过。
 * </p>
 * Created by zhumenglong on 2017/5/29.
 */
public abstract class JedisHashPackHandler extends JedisListPackHandler implements IRedisHashPack{

    public JedisHashPackHandler(Pool<? extends JedisCommands> redisPool) {
        super(redisPool);
    }

    @Override
    public long dbsize() {
        RedisResultTask<Long,Jedis> task = (jedis) -> {
            return jedis.dbSize();
        };
        return ((Long) this.run(task)).longValue();
    }

    @Override
    public void flushDB() {
        RedisTask<Jedis> task = (jedis) -> {
            jedis.flushDB();
        };
        this.run(task);
    }
}
